<?php

namespace App\Models;

use App\Util\Url;
use Illuminate\Database\Eloquent\Model;

class CarouselPicCategory extends Model
{
    protected $table = 'c_carousel_pic_categories';

    /***
     * @param $filter
     * @return array
     * 获取轮播图
     */
    public function getImages($filter)
    {
        $res = $this->where([['carousel_pic_id', '=', $filter['cate_id']]])->get();
        $host  = new Url();
        foreach($res as $k=>$v){
            $v->pic =$host::getHttpHost().'upload/'.$v->pic;
        }
        if (!empty($res)) {
            return $res->toArray();
        }
        return [];
    }
}
